﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mailias.UI.Web.Infrastructure;

namespace Mailias.UI.Web.Models
{
    public class MailiasSettingsViewModel
    {
        public SmtpSettingsViewModel SmtpSettings { get; set; }
        
        internal static MailiasSettingsViewModel Create(MailiasSettings settings )
        {
            return new MailiasSettingsViewModel()
                       {
                           SmtpSettings = new SmtpSettingsViewModel()
                           {
                               Address = (settings == null) ? "127.0.0.1" : settings.SmtpSettings.Address,
                               Port = (settings == null) ? 8025 : settings.SmtpSettings.Port
                           }
                       };
        }

        internal MailiasSettings CreateSmtpServerSettings ()
        {
            return new MailiasSettings()
                       {
                           SmtpSettings = new SmtpSettings()
                               {
                                   Address = this.SmtpSettings.Address,
                                   Port = this.SmtpSettings.Port
                               }
                       };
        }
    }

    public class SmtpSettingsViewModel
    {
        public string Address { get; set; }
        public int Port { get; set; }
    }
}